﻿<UserControl x:Class="MediaBrowserSL.RIA.Views.PageMusicView"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:c="clr-namespace:DC.ControlLibrary;assembly=DC.ControlLibrary"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:eventToCmd="clr-namespace:JulMar.Siverlight.Helpers.Interactivity;assembly=JulMar.Siverlight.Helpers"
    xmlns:Converters="clr-namespace:MediaBrowserSL.RIA.Converters"
    xmlns:MediaBrowserSL_RIA_CustomControls="clr-namespace:MediaBrowserSL.RIA.Views.CustomControls"
    xmlns:julmarConverter="clr-namespace:JulMar.Silverlight.Converters;assembly=JulMar.Siverlight.Helpers"
    xmlns:jadeControls="http://www.sebastien-alves.fr/jadeToolsSLControls"
    mc:Ignorable="d" d:DesignHeight="480" d:DesignWidth="640">

    <UserControl.DataContext>
        <Binding Mode="OneWay" Path="Musics" Source="{StaticResource Locator}"/>
    </UserControl.DataContext>

    <UserControl.Resources>
        <julmarConverter:NotBooleanConverter x:Key="notBooleanConverter" />
    </UserControl.Resources>


    <Grid x:Name="LayoutRoot">

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="240" />
        </Grid.ColumnDefinitions>

        <Grid Grid.Column="0">
            <Grid.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#33181818"/>
                    <GradientStop Color="#337A7A7A" Offset="0.5"/>
                    <GradientStop Color="#CC1A1A1A" Offset="1"/>
                </LinearGradientBrush>
            </Grid.Background>

            <c:CoverFlowControl  x:Name="CoverFlow" SpaceBetweenItems="30" ItemsSource="{Binding MediasView}"  Margin="0" ItemContainerStyle="{StaticResource DefaultListBoxItemStyle}">
                <c:CoverFlowControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <jadeControls:ImageLoader Source="{Binding UrlImage}" Height="400" Width="300"/>
                            <jadeControls:ImageLoader Source="{Binding UrlImage}"
                       Height="400" Width="300"
                       RenderTransformOrigin="0.5,1.0">
                                <jadeControls:ImageLoader.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleY="-1"/>
                                        <TranslateTransform Y="3"/>
                                    </TransformGroup>
                                </jadeControls:ImageLoader.RenderTransform>
                                <jadeControls:ImageLoader.OpacityMask>
                                    <LinearGradientBrush StartPoint="0.5,0"
                                             EndPoint="0.5,1">
                                        <GradientStop Color="#00000000" Offset="0.0"/>
                                        <GradientStop Color="#00000000" Offset="0.7"/>
                                        <GradientStop Color="#FFFFFFFF" Offset="1.0"/>
                                    </LinearGradientBrush>
                                </jadeControls:ImageLoader.OpacityMask>
                            </jadeControls:ImageLoader>
                        </Grid>
                    </DataTemplate>
                </c:CoverFlowControl.ItemTemplate>
            </c:CoverFlowControl>

            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="1,0,0,0" >
                <jadeControls:ImageButton x:Name="btAdd" Command="{Binding PrepareAddAlbumCommand}" Source="/MediaBrowserSL.RIA;Component/Images/cd_add.png" Height="16" Margin="0,0,5,0" Width="16" ToolTipService.ToolTip="Ajouter un album"/>
                <jadeControls:ImageButton x:Name="btUp" Command="{Binding PrepareUpdateAlbumCommand}" Source="/MediaBrowserSL.RIA;Component/Images/cd_edit.png" Height="16" Margin="0,0,5,0" Width="16" ToolTipService.ToolTip="Editer cet album"/>
                <Grid Margin="0,0,1,0">
                    <jadeControls:ImageButton Command="{Binding DeleteAlbumCommand}" Source="/MediaBrowserSL.RIA;Component/Images/cd_delete.png" Height="16" Margin="0,0,1,0" Width="16" ToolTipService.ToolTip="Supprimer cet album"/>
                    <jadeControls:Loading IsLoading="{Binding IsDeleting}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </Grid>
            </StackPanel>
        </Grid>

        <!--RIGHT-->
        <Grid Grid.Column="1" Margin="5,0,0,0" >

            <Grid.RowDefinitions>
                <RowDefinition Height="20"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <jadeControls:Loading Grid.RowSpan="2" IsLoading="{Binding IsDroping}" HorizontalAlignment="Center" VerticalAlignment="Center" />

            <Border Grid.Row="0" BorderThickness="1,1,1,0" CornerRadius="0,0,1,1" Background="{StaticResource BackGrdCustom}" BorderBrush="{StaticResource NormalBorderBrush}">
                <sdk:Label Content="Liste des Titres" Foreground="White" Margin="5,0,0,0" />
            </Border>

            <Border Grid.Row="1" BorderThickness="2,0,2,2" CornerRadius="0,0,4,4" Padding="4" BorderBrush="{StaticResource NormalBorderBrush}" AllowDrop="True" ToolTipService.ToolTip="Glisser-déposer pour ajouter une nouvelle musique">

                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Drop">
                        <eventToCmd:EventToCommand Command="{Binding DropMusicCommand}" />
                    </i:EventTrigger>
                    <i:EventTrigger EventName="KeyDown">
                        <eventToCmd:EventToCommand Command="{Binding DeleteMusicCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>

                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#19000000" Offset="0"/>
                        <GradientStop Color="#6656747A" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>

                <ListBox x:Name="lMusic" ItemsSource="{Binding MediaItemsView}" DisplayMemberPath="Name"  Background="{x:Null}"
                         IsEnabled="{Binding IsDroping, Converter={StaticResource notBooleanConverter}}"/>

            </Border>

            <!--PANEL CONTROL MUSIC-->

            <Border Grid.Row="2" Margin="0" CornerRadius="1,1,2,2">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#B24B5059" Offset="0"/>
                        <GradientStop Color="#CC838C9B" Offset="0.985"/>
                    </LinearGradientBrush>
                </Border.Background>

                <Grid Margin="5,0,5,5" Height="60" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <Grid Grid.Row="0">
                        <Slider Maximum="{Binding TotalDuration}" Value="{Binding CurrentPosition, Mode=TwoWay}" Style="{StaticResource TrackSlider}"/>
                    </Grid>

                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="110"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <StackPanel Orientation="Horizontal" Grid.Column="0" >
                            <Button Style="{StaticResource PlayButtonStyle}" Command="{Binding PlayMusicCommand}" Height="24" Width="24" Margin="0,0,5,0" />
                            <Button Style="{StaticResource PauseButtonStyle}" Command="{Binding PauseMusicCommand}" Height="24" Width="24" Margin="5,0,0,0"/>
                            <Button Style="{StaticResource StopButtonStyle}" Command="{Binding StopMusicCommand}" Height="24" Width="24" Margin="10,0,0,0" Padding="0" />
                        </StackPanel>

                        <StackPanel Orientation="Vertical" Grid.Column="1" Margin="10,0,0,0">
                            <StackPanel Orientation="Horizontal">
                                <MediaBrowserSL_RIA_CustomControls:MuteButtonControl Height="23" Width="22"/>
                                <Slider Style="{StaticResource VolumeSlider}" Maximum="1" LargeChange="0.5" Value="{Binding Volume, ElementName=mediaElement, Mode=TwoWay}"  Width="80" Height="16" Margin="0" HorizontalAlignment="Left" />
                            </StackPanel>
                            <TextBlock x:Name="ProgressDisplay" Text="{Binding CurrentProgress, Mode=OneWay}" Foreground="#FFFAF7F7" HorizontalAlignment="Left" FontSize="10" Margin="5,0,0,0" />
                            <MediaElement x:Name="mediaElement" AutoPlay="False" d:IsHidden="True" Visibility="Collapsed" Source="{Binding CurrentMediaItem.UrlContent}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="MediaOpened">
                                        <eventToCmd:EventToCommand Command="{Binding MediaOpenedCommand}" CommandParameter="{Binding ElementName=mediaElement}" />
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="MediaFailed">
                                        <eventToCmd:EventToCommand Command="{Binding MediaFailedCommand}" CommandParameter="{Binding}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </MediaElement>
                        </StackPanel>
                    </Grid>
                </Grid>
            </Border>

            <!--PANEL CONTROL MUSIC-->

        </Grid>

        <!--RIGHT-->

    </Grid>
</UserControl>
